Imports BusinessLayer
Imports EntityLayer
Imports System.Data

Partial Class VistaProductoProveedor
    Inherits System.Web.UI.Page


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            ListarProveedor()
           Dim strCodigo As String
            strCodigo = Request.QueryString("strCodigo")

            ddlProveedor.SelectedValue = strCodigo
            LlenarProveedor()

            Session("myDatatable") = ProductoProveedorBL.ListarxCodigo(ddlProveedor.SelectedValue).Tables(0)

            dgDatos.DataSource = CType(Session("myDatatable"), DataTable).DefaultView
            dgDatos.DataBind()
        End If

    End Sub

    Protected Sub btnCancelar_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Response.Redirect("ListaProductoProveedor.aspx")
    End Sub

    Private Sub ListarProveedor()
        ddlProveedor.DataSource = ProveedorBL.ListarTodo()
        ddlProveedor.DataTextField = "RazonSocial"
        ddlProveedor.DataValueField = "CodigoPro"
        ddlProveedor.DataBind()

    End Sub

    Private Sub LlenarProveedor()
        Dim dt As DataTable
        dt = ProveedorBL.ListarxCodigo(ddlProveedor.SelectedValue).Tables(0)

        txtDireccion.Text = dt.Rows(0)(2).ToString
        txtRubro.Text = dt.Rows(0)(3).ToString
        txtcontacto.Text = dt.Rows(0)(4).ToString
        txtTelefono.Text = dt.Rows(0)(5).ToString
        txtEmail.Text = dt.Rows(0)(6).ToString
        txtWeb.Text = dt.Rows(0)(7).ToString
        txtRUC.Text = dt.Rows(0)(8).ToString

    End Sub


End Class
